/*
 * Copyright (C) 2012 SeekDeepWithin.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package com.seekdeepwithin.DataAccess;

import javafx.beans.property.*;
import javafx.concurrent.*;

/**
 * User: Jonathan Montiverdi
 * Date: Oct 10, 2012
 *
 * A threaded service to run a search.
 */
public class BookSearchService extends Service<String>
{
    private StringProperty searchText = new SimpleStringProperty ();

    /**
     * Sets the text to search for.
     * @param text The text to search for.
     */
    public final void setSearchText (String text)
    {
        this.searchText.set (text);
    }

    /**
     * Gets the text to search for.
     * @return The text to search for.
     */
    public final String getSearchText ()
    {
        return this.searchText.get ();
    }

    /**
     * Gets the search text property.
     * @return Search text property.
     */
    public final StringProperty searchTextProperty ()
    {
        return this.searchText;
    }

    /**
     * Creates the task that performs the action.
     * @return Newly created task.
     */
    @Override
    protected Task<String> createTask ()
    {
        final String m_SearchText = getSearchText ();
        return new Task<String> () {
            @Override protected String call ()
            {
                StringBuilder resultsHtml = new StringBuilder ("<table width=\"100%\" class=\"search\"><tbody>");
                resultsHtml.append ("</tbody></table>");
                return resultsHtml.toString ();
            }
        };
    }

}
